package com.wu.llpsw.item.wubing;

import com.wu.llpsw.yuanli.energy.yuanliManager;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class diding extends Item {
    public diding(Properties p_41383_) {
        super(p_41383_);
    }




    //攻击生物
    @Override
    public boolean hurtEnemy(ItemStack itemStack, LivingEntity attacked, LivingEntity attack) {
        AttributeInstance attackobject=attack.getAttribute(Attributes.ATTACK_DAMAGE);
        double value=attackobject.getValue();
        attacked.hurt(DamageSource.GENERIC, (float) (10*value));
        //被攻击到会减速
        attacked.addEffect(new MobEffectInstance(MobEffects.SLOW_FALLING, 20 * 5, 1));
        return true;
    }


    //添加描述
    @Override
    public void appendHoverText(ItemStack p_41421_, @Nullable Level p_41422_, List<Component> p_41423_, TooltipFlag p_41424_) {
        p_41423_.add(new TranslatableComponent("tooltip.wu.diding.tooltip"));
    }
}
